<?php

function import($moduleName) {
    if (file_exists(DSF_MODDIR . DS . $moduleName . '.php')) {
        require_once DSF_MODDIR . DS . $moduleName . '.php';
    } else {
        echo "{$moduleName} nie istnieje!";
    }
}

function runSite(array $UrlPathArray) {
    $_controller = (isset($UrlPathArray[0])) ? $UrlPathArray[0] : DSF_URLDEFCONT;
    $_action = (isset($UrlPathArray[1]) && $UrlPathArray[1] != "") ? $UrlPathArray[1] : DSF_URLDEFACT;
    unset($UrlPathArray[0], $UrlPathArray[1]);
    if (file_exists(DSF_CONTDIR . DS . $_controller . '.php')) {
        require_once DSF_CONTDIR . DS . $_controller . '.php';
        if (!function_exists("{$_action}_action")) {
            RunSite([]);
        } else {
            call_user_func_array($_action . '_action', $UrlPathArray);
        }
    } else {
        RunSite([]);
    }
}

function loadCoreLibs(array $libsArray) {
    foreach ($libsArray as $file) {
        if (file_exists($fileName = DSF_SYSDIR . DS . $file . '.php'))
            require_once $fileName;
    }
}